package io.github.lee.app.unsplash.repository.dao

import androidx.room.Dao
import androidx.room.Query
import io.github.lee.app.unsplash.repository.domain.SearchKeyword
import io.github.lee.core.dao.BaseRoomDao
import kotlinx.coroutines.flow.Flow

@Dao
interface SearchKeywordDao : BaseRoomDao<SearchKeyword> {


    @Query("SELECT * FROM searchkeyword ORDER BY updateTime DESC LIMIT :count")
    fun queryByCount(count: Int): Flow<List<SearchKeyword>>

    @Query("SELECT * FROM searchkeyword WHERE keyword = :keyword")
    fun queryByWord(keyword: String): SearchKeyword?


    @Query("DELETE FROM searchkeyword")
    fun deleteAll()
}